@extends('admin.admin')
@section('content-header')
    {{--<h1>--}}
        {{--用户管理--}}
        {{--<small>个人资料</small>--}}
    {{--</h1>--}}
    {{--<ol class="breadcrumb">--}}
        {{--<li><a href="{{url('/dashboard')}}"><i class="fa fa-dashboard"></i> 主页</a></li>--}}
        {{--<li class="active"><a href="{{url('/admin/info/index')}}">用户管理 - 个人资料</a></li>--}}
    {{--</ol>--}}
@stop

@section('content')
    <div class="panel">
        <div class="panel-body">
            <table id="demo-foo-filtering" class="table table-bordered table-hover toggle-circle" data-page-size="7">
                <div class="pad-btm form-inline" style="margin-bottom: 10px;">
                    <div class="row">
                        @include('admin.partials.errors')
                        @include('admin.partials.success')
                    </div>
                    <div class="row">
                        <div class="col-sm-6 text-xs-center" id='element_id'>
                            {{--<form action="{{ route('admin.school.index') }}" method="post">--}}
                            <form action="{{ url('admin/code/index') }}" method="post">
                                {{csrf_field()}}
                                {{--<input type="hidden" name="_method" value="get">--}}
                                <div class="form-group">
                                    <input id="demo-foo-search" type="text" placeholder="用户名搜索" class="form-control" autocomplete="off" name="name" value="{{$search['name'] or ''}}">
                                </div>
                                &nbsp;&nbsp;&nbsp;
                                <button class="btn btn-primary">搜索</button>
                                <a class="btn btn-primary" href="{{ url('admin/tixina/index') }}">清空查询</a>
                            </form>
                        </div>
                    </div>
                </div>
                <thead>
                <tr>
                    <th>ID</th>
                    <th>申请人</th>
                    <th>手机号</th>
                    <th>收款人</th>
                    <th>提现码</th>
                    <th>剩余金额</th>
                    <th>提现金额</th>
                    <th>状态</th>
                    <th>申请时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $k => $v)
                    <tr class="tr" data-cid="{{$v->uid}}">
                        <td>{{$v->id}}</td>
                        <td>{{ $v->username }}</td>
                        <td>{{ $v->mobile }}</td>
                        <td>{{ $v->name }}</td>
                        <td><a href="{{ $v->img }}" target="_blank"><img src="{{ $v->img }}" alt="" style="width: 50px;height: 50px;" ></a></td>
                        <td>{{ sprintf("%.2f",$v->balance/100) }}元</td>
                        <td>{{ sprintf("%.2f",$v->money/100) }}元</td>
                        <td>
                            @if($v->status == 0)
                                <span class="text-danger">未处理</span>
                            @else
                                <span class="text-success">已处理</span>
                            @endif
                        </td>
                        <td>{{ $v->created_at }}</td>
                        <td>
                            @if($v->status == 0)
                                <a style="margin:3px;" href="#" data-id="{{$v->id}}" data-money="{{$v->money}}" data-balance="{{$v->balance}}" class="use X-Small btn-xs text-success "><i class="fa fa-times-circle-o"></i> 处理</a>
                            @endif
                        </td>
                    </tr>
                @endforeach

                </tbody>
                <tfoot>
                <tr>
                    <td colspan="10">
                        <div class="text-right">
                            {!! $data->appends(['name' => $search['name']])->render() !!}
                        </div>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>

    </div>

@stop

@section('script')
    <script>
        $(document).on('click', '.use', function () {
            var id = $(this).data('id');
            var money = $(this).data('money');
            var balance = $(this).data('balance');
            if( money > balance){
                alert('余额不足');
                return
            }
            var urls = "{{ url('admin/tixian/up_down') }}";
            $.get(urls, {id: id,money:money,balance:balance}, function (data) {
                console.log(data);
                if (data.code == 0) {
                    window.location.reload();
                }

            });
        });
    </script>

@stop

